# -*- coding:utf-8 -*-
"""
登录页面
by 张润庶
"""
from testlib.ui.pages.BasePage import BasePage
from testlib.ui.locator.LoginPageLocator import locator
import time
import logging

log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())


class LoginPage(BasePage):

    def open_browser(self, url):
        """
            启动游览器，并打开登录页面
        :param ip: ip
        :return:
        """
        self.driver.get(url)
        self.driver.maximize_window()


    def login(self, username, password):
        """
            登录系统
        :param username: 用户名
        :param password: 密码
        :return:
        """
        # 输入账号
        logging.info("输入账号: {}".format(username))
        self.input(*locator['用户名'], username)
        # 输入密码
        logging.info("输入密码: {}".format(password))
        self.input(*locator['密码'], password)
        # 点击登录
        logging.info("点击登录")
        self.click(*locator['登录'])


if __name__ == '__main__':
    login_page = LoginPage()
    login_page.open_browser("127.0.0.1")
    login_page.login("XXX", "XXXXXX")

